home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / qrymod / qrymod.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-18  |  2.2 KB  |  124 lines

  1. # include    <ingres.h>
  2. # include    <aux.h>
  3. # include    <pv.h>
  4. # include    <opsys.h>
  5. # include    <func.h>
  6. # include    <tree.h>
  7. # include    "qrymod.h"
  8.  
  9.  
  10. /*
  11. **  QRYMOD -- query modification process
  12. **
  13. **    This process modifies queries to implement views, protection,
  14. **    and integrity.
  15. **
  16. **    Return Codes:
  17. **        standard
  18. **
  19. **    Trace Flags:
  20. **        none.
  21. */
  22.  
  23.  
  24. DESC        Prodes;        /* protection catalog descriptor */
  25. DESC        Reldes;        /* relation catalog descriptor */
  26. DESC        Treedes;    /* tree catalog descriptor */
  27. DESC        Intdes;        /* integrity catalog descriptor */
  28. extern int    Equel;        /* equel flag */
  29.  
  30. # define TTYIDSIZE    8    /* length of tty id */
  31.  
  32. extern    qrymod(), qm_init(), null_fn();
  33. short    tTqm[80];
  34. char    Terminal[TTYIDSIZE + 1];
  35.  
  36. struct fn_def    QryModFn =
  37. {
  38.     "QRYMOD",
  39.     qrymod,
  40.     qm_init,
  41.     null_fn,
  42.     (char *) &Qm,
  43.     sizeof Qm,
  44.     tTqm,
  45.     80,
  46.     'Q',
  47.     0,
  48. };
  49.  
  50.  
  51.  
  52. qm_init(argc, argv)
  53. int    argc;
  54. char    **argv;
  55. {
  56. #    ifdef xV7_UNIX
  57.     extern char    *ttyname();
  58.     extern char    *rindex();
  59.     char        *tty;
  60. #    endif
  61.  
  62.     /* determine user's terminal for protection algorithm */
  63.     if ((tty = ttyname(1)) != NULL)
  64.         tty = rindex(tty, '/') + 1; 
  65.     pmove((tty != NULL ? tty : " "), Terminal, TTYIDSIZE, ' ');
  66.     Terminal[TTYIDSIZE] = '\0';
  67. # ifdef xQTR1
  68.     if (tTf(75, 0))
  69.         printf("Terminal = \"%s\"\n", Terminal);
  70. # endif
  71. }
  72. /*
  73. **  QRYMOD -- main driver for query modification
  74. **
  75. **    Reads in the query tree, performs the modifications, writes
  76. **    it out, and does process syncronization with below.  The
  77. **    calling routine must sync with the process above.
  78. **
  79. **    Parameters:
  80. **        pc -- parameter count (must = 1).
  81. **        pv -- parameter vector:
  82. **            pv[0] -- tree to modify.
  83. **
  84. **    Returns:
  85. **        zero.
  86. **
  87. **    Side Effects:
  88. **        The tree is modified to one that is guaranteed to
  89. **        be directly processable.
  90. **
  91. **    Trace Flags:
  92. **        none.
  93. */
  94.  
  95.  
  96. qrymod(pc, pv)
  97. int    pc;
  98. PARM    *pv;
  99. {
  100.     register QTREE    *root;
  101.     extern QTREE    *view(), *integrity(), *protect();
  102.  
  103.     /*
  104.     **  Get parameters.
  105.     */
  106.  
  107.     if (pc != 1)
  108.         syserr("pc=%d", pc);
  109.     if (pv[0].pv_type != PV_QTREE)
  110.         syserr("pv[0].type=%d", pv[0].pv_type);
  111.     root = pv[0].pv_val.pv_qtree;
  112.  
  113.     /* view processing */
  114.     root = view(root);
  115.  
  116.     /* integrity processing */
  117.     root = integrity(root);
  118.  
  119.     /* protection processing */
  120.     root = protect(root);
  121.  
  122.     return (0);
  123. }
  124.